package org.komarichin.beans.service;

import org.komarichin.beans.IFile;

import java.io.Serializable;
import java.util.Collection;

/**
 * User: Mykhaylo Komarichyn
 * Date: 31.12.2009
 * Time: 12:33:25
 */
public interface IFileService<PK> extends Serializable {

    public IFile<PK> createBlank();

    /**
     * save entity
     *
     * @param file saving entity
     * @return saved entity
     */

    public IFile<PK> save(IFile<PK> file);

    public IFile<PK> save(IFile<PK> file, IFile<PK> folder);

    /**
     * save or update entity
     *
     * @param file saving or updation entity
     */
    public void saveOrUpdate(IFile<PK> file);

    /**
     * @param file removed entity
     */
    public void delete(IFile<PK> file);

    /**
     * @param id identifier removed entity
     */
    public void delete(PK id);

    /**
     * @param id identifier finding entity
     * @return found entity
     */
    public IFile<PK> getFile(PK id);

    /**
     * @param folderName folder from it will find entities
     * @return collection of entities
     */
    public Collection<IFile<PK>> getFiles(String folderName);

    /**
     * @param folderName folder from it will find entities (folder and file)
     * @return collection of files
     */
    public Collection<IFile<PK>> getFilesAndFolders(String folderName);

    /**
     * @param fileName file name
     * @param folder   folder path
     * @return true if file exists in folder
     */
    public boolean exists(String fileName, String folder);

    /**
     * @param folder entity name
     * @return true if folder empty
     */
    public boolean isFolderEmpty(String folder);

    /**
     * @param currentFolder current folder
     * @return collection of file names
     */
    public Collection<String> getFolders(String currentFolder);
}
